﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSLib.CodeFormating.Lexems;

namespace PSLib.CodeFormating.Formatters
{
	[Serializable]
	public class LexemConfiguration
	{
		public LexemConfiguration(LexemType type)
		{
			replacement = new Dictionary<string, string>();
			this.LexemType = type;
		}

		public LexemConfiguration Clone()
		{
			LexemConfiguration str = new LexemConfiguration(this.LexemType);
			str.Name = this.Name;
			str.Description = this.Description;
			str.LexemType = this.LexemType;
			str.Postfix = this.Postfix;
			str.Prefix = this.Prefix;
			foreach (var item in this.ReplacementCollection)
				str.ReplacementCollection.Add(item.Key, item.Value);

			return str;
		}

		public string Name { get; set; }
		public string Description { get; set; }
		public string Prefix { get; set; }
		public string Postfix { get; set; }

		public Dictionary<string, string> ReplacementCollection 
		{
			get { return replacement; }
		}
		
		public LexemType LexemType { get; internal set; }

		public override string ToString()
		{
			string result = "LC:<" + LexemType.ToString() + "> ";
			if (!string.IsNullOrEmpty(this.Name)) result += this.Name;
			return result;
		}

		private Dictionary<string, string> replacement;
	}
}
